home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / gnu-c / src / gcc-2.7.0-amiga / ginclude / stddef.h < prev    next >
C/C++ Source or Header  |  1995-08-24  |  10KB  |  352 lines

  1. #ifndef _STDDEF_H
  2. #ifndef _STDDEF_H_
  3. #ifndef _ANSI_STDDEF_H
  4. #ifndef __STDDEF_H__
  5.  
  6. #ifdef __amigados__
  7.  
  8. /* GNU libc has special support in this file, 4.3bsd-net2 libc deserves that
  9.    just as well. The system headers are ANSI compliant, the used compiler IS
  10.    gcc, so it's really ok to use the system header, no reason to hassle
  11.    with a jungle of ifdefs. Besides, amigados is only defined if compiling
  12.    with host=amigados, it doesn't apply if compiling with target=amigados
  13.    on a different host with possibly different system headers. Same thing
  14.    would apply to gstdarg.h and gvarargs.h, but those headers are more
  15.    easily fixable than this one and I'm sick of writing the same comment
  16.    there as well. MW
  17.  
  18.    Include the contents of <stddef.h> inline rather than with a #include,
  19.    to avoid infinite include recursion when this file is installed in
  20.    gcc's include directory as stddef.h.  (fnf)  */
  21.  
  22. #define _STDDEF_H_
  23.  
  24. #include <machine/ansi.h>
  25.  
  26. typedef    _PTRDIFF_T_    ptrdiff_t;
  27.  
  28. #ifdef    _SIZE_T_
  29. typedef    _SIZE_T_    size_t;
  30. #undef    _SIZE_T_
  31. #endif
  32.  
  33. #ifdef    _WCHAR_T_
  34. typedef    _WCHAR_T_    wchar_t;
  35. #undef    _WCHAR_T_
  36. #endif
  37.  
  38. #ifndef    NULL
  39. #define    NULL    0
  40. #endif
  41.  
  42. #define    offsetof(type, member)    ((size_t)(&((type *)0)->member))
  43.  
  44. #else /* not __amigados__ */
  45.  
  46. /* Any one of these symbols __need_* means that GNU libc
  47.    wants us just to define one data type.  So don't define
  48.    the symbols that indicate this file's entire job has been done.  */
  49. #if (!defined(__need_wchar_t) && !defined(__need_size_t)    \
  50.      && !defined(__need_ptrdiff_t) && !defined(__need_NULL))
  51. #define _STDDEF_H
  52. #define _STDDEF_H_
  53. /* snaroff@next.com says the NeXT needs this.  */
  54. #define _ANSI_STDDEF_H
  55. /* Irix 5.1 needs this.  */
  56. #define __STDDEF_H__
  57. #endif
  58.  
  59. #ifndef __sys_stdtypes_h
  60. /* This avoids lossage on SunOS but only if stdtypes.h comes first.
  61.    There's no way to win with the other order!  Sun lossage.  */
  62.  
  63. /* On 4.3bsd-net2, make sure ansi.h is included, so we have
  64.    one less case to deal with in the following.  */
  65. #if defined (__BSD_NET2__) || defined (____386BSD____) || defined (__FreeBSD__) || defined(__NetBSD__)
  66. #include <machine/ansi.h>
  67. #endif
  68.  
  69. /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
  70.    defined if the corresponding type is *not* defined.
  71.    FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_ */
  72. #if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_)
  73. #if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)
  74. #define _SIZE_T
  75. #endif
  76. #if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)
  77. #define _PTRDIFF_T
  78. #endif
  79. /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
  80.    instead of _WCHAR_T_. */
  81. #if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)
  82. #ifndef _BSD_WCHAR_T_
  83. #define _WCHAR_T
  84. #endif
  85. #endif
  86. /* Undef _FOO_T_ if we are supposed to define foo_t.  */
  87. #if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)
  88. #undef _PTRDIFF_T_
  89. #undef _BSD_PTRDIFF_T_
  90. #endif
  91. #if defined (__need_size_t) || defined (_STDDEF_H_)
  92. #undef _SIZE_T_
  93. #undef _BSD_SIZE_T_
  94. #endif
  95. #if defined (__need_wchar_t) || defined (_STDDEF_H_)
  96. #undef _WCHAR_T_
  97. #undef _BSD_WCHAR_T_
  98. #endif
  99. #endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) */
  100.  
  101. /* Sequent's header files use _PTRDIFF_T_ in some conflicting way.
  102.    Just ignore it.  */
  103. #if defined (__sequent__) && defined (_PTRDIFF_T_)
  104. #undef _PTRDIFF_T_
  105. #endif
  106.  
  107. /* On VxWorks, <type/vxTypesBase.h> may have defined macros like
  108.    _TYPE_size_t which will typedef size_t.  fixincludes patched the
  109.    vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is
  110.    not defined, and so that defining this macro defines _GCC_SIZE_T.
  111.    If we find that the macros are still defined at this point, we must
  112.    invoke them so that the type is defined as expected.  */
  113. #if defined (TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))
  114. _TYPE_ptrdiff_t;
  115. #undef _TYPE_ptrdiff_t
  116. #endif
  117. #if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_))
  118. _TYPE_size_t;
  119. #undef _TYPE_size_t
  120. #endif
  121. #if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_))
  122. _TYPE_wchar_t;
  123. #undef _TYPE_wchar_t
  124. #endif
  125.  
  126. /* In case nobody has defined these types, but we aren't running under
  127.    GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and
  128.    __WCHAR_TYPE__ have reasonable values.  This can happen if the
  129.    parts of GCC is compiled by an older compiler, that actually
  130.    include gstddef.h, such as collect2.  */
  131.  
  132. /* Signed type of difference of two pointers.  */
  133.  
  134. /* Define this type if we are doing the whole job,
  135.    or if we want this type in particular.  */
  136. #if defined (_STDDEF_H) || defined (__need_ptrdiff_t)
  137. #ifndef _PTRDIFF_T    /* in case <sys/types.h> has defined it. */
  138. #ifndef _T_PTRDIFF_
  139. #ifndef _T_PTRDIFF
  140. #ifndef __PTRDIFF_T
  141. #ifndef _PTRDIFF_T_
  142. #ifndef _BSD_PTRDIFF_T_
  143. #ifndef ___int_ptrdiff_t_h
  144. #ifndef _GCC_PTRDIFF_T
  145. #define _PTRDIFF_T
  146. #define _T_PTRDIFF_
  147. #define _T_PTRDIFF
  148. #define __PTRDIFF_T
  149. #define _PTRDIFF_T_
  150. #define _BSD_PTRDIFF_T_
  151. #define ___int_ptrdiff_t_h
  152. #define _GCC_PTRDIFF_T
  153. #ifndef __PTRDIFF_TYPE__
  154. #define __PTRDIFF_TYPE__ long int
  155. #endif
  156. typedef __PTRDIFF_TYPE__ ptrdiff_t;
  157. #endif /* _GCC_PTRDIFF_T */
  158. #endif /* ___int_ptrdiff_t_h */
  159. #endif /* _BSD_PTRDIFF_T_ */
  160. #endif /* _PTRDIFF_T_ */
  161. #endif /* __PTRDIFF_T */
  162. #endif /* _T_PTRDIFF */
  163. #endif /* _T_PTRDIFF_ */
  164. #endif /* _PTRDIFF_T */
  165.  
  166. /* If this symbol has done its job, get rid of it.  */
  167. #undef    __need_ptrdiff_t
  168.  
  169. #endif /* _STDDEF_H or __need_ptrdiff_t.  */
  170.  
  171. /* Unsigned type of `sizeof' something.  */
  172.  
  173. /* Define this type if we are doing the whole job,
  174.    or if we want this type in particular.  */
  175. #if defined (_STDDEF_H) || defined (__need_size_t)
  176. #ifndef _SIZE_T    /* in case <sys/types.h> has defined it. */
  177. #ifndef _SYS_SIZE_T_H
  178. #ifndef _T_SIZE_
  179. #ifndef _T_SIZE
  180. #ifndef __SIZE_T
  181. #ifndef _SIZE_T_
  182. #ifndef _BSD_SIZE_T_
  183. #ifndef _SIZE_T_DEFINED_
  184. #ifndef _SIZE_T_DEFINED
  185. #ifndef ___int_size_t_h
  186. #ifndef _GCC_SIZE_T
  187. #ifndef _SIZET_
  188. #ifndef __size_t
  189. #define _SIZE_T
  190. #define _SYS_SIZE_T_H
  191. #define _T_SIZE_
  192. #define _T_SIZE
  193. #define __SIZE_T
  194. #define _SIZE_T_
  195. #define _BSD_SIZE_T_
  196. #define _SIZE_T_DEFINED_
  197. #define _SIZE_T_DEFINED
  198. #define ___int_size_t_h
  199. #define _GCC_SIZE_T
  200. #define _SIZET_
  201. #define __size_t
  202. #ifndef __SIZE_TYPE__
  203. #define __SIZE_TYPE__ long unsigned int
  204. #endif
  205. #if !(defined (__GNUG__) && defined (size_t))
  206. typedef __SIZE_TYPE__ size_t;
  207. #endif /* !(defined (__GNUG__) && defined (size_t)) */
  208. #endif /* __size_t */
  209. #endif /* _SIZET_ */
  210. #endif /* _GCC_SIZE_T */
  211. #endif /* ___int_size_t_h */
  212. #endif /* _SIZE_T_DEFINED */
  213. #endif /* _SIZE_T_DEFINED_ */
  214. #endif /* _BSD_SIZE_T_ */
  215. #endif /* _SIZE_T_ */
  216. #endif /* __SIZE_T */
  217. #endif /* _T_SIZE */
  218. #endif /* _T_SIZE_ */
  219. #endif /* _SYS_SIZE_T_H */
  220. #endif /* _SIZE_T */
  221. #undef    __need_size_t
  222. #endif /* _STDDEF_H or __need_size_t.  */
  223.  
  224.  
  225. /* Wide character type.
  226.    Locale-writers should change this as necessary to
  227.    be big enough to hold unique values not between 0 and 127,
  228.    and not (wchar_t) -1, for each defined multibyte character.  */
  229.  
  230. /* Define this type if we are doing the whole job,
  231.    or if we want this type in particular.  */
  232. #if defined (_STDDEF_H) || defined (__need_wchar_t)
  233. #ifndef _WCHAR_T
  234. #ifndef _T_WCHAR_
  235. #ifndef _T_WCHAR
  236. #ifndef __WCHAR_T
  237. #ifndef _WCHAR_T_
  238. #ifndef _BSD_WCHAR_T_
  239. #ifndef _WCHAR_T_DEFINED_
  240. #ifndef _WCHAR_T_DEFINED
  241. #ifndef _WCHAR_T_H
  242. #ifndef ___int_wchar_t_h
  243. #ifndef __INT_WCHAR_T_H
  244. #ifndef _GCC_WCHAR_T
  245. #define _WCHAR_T
  246. #define _T_WCHAR_
  247. #define _T_WCHAR
  248. #define __WCHAR_T
  249. #define _WCHAR_T_
  250. #define _BSD_WCHAR_T_
  251. #define _WCHAR_T_DEFINED_
  252. #define _WCHAR_T_DEFINED
  253. #define _WCHAR_T_H
  254. #define ___int_wchar_t_h
  255. #define __INT_WCHAR_T_H
  256. #define _GCC_WCHAR_T
  257.  
  258. /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
  259.    instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
  260.    symbols in the _FOO_T_ family, stays defined even after its
  261.    corresponding type is defined).  If we define wchar_t, then we
  262.    must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if
  263.    we undef _WCHAR_T_, then we must also define rune_t, since 
  264.    headers like runetype.h assume that if machine/ansi.h is included,
  265.    and _BSD_WCHAR_T_ is not defined, then rune_t is available.
  266.    machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of
  267.    the same type." */
  268. #ifdef _BSD_WCHAR_T_
  269. #undef _BSD_WCHAR_T_
  270. #ifdef _BSD_RUNE_T_
  271. #if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
  272. typedef _BSD_RUNE_T_ rune_t;
  273. #endif
  274. #endif
  275. #endif
  276.  
  277. #ifndef __WCHAR_TYPE__
  278. #define __WCHAR_TYPE__ int
  279. #endif
  280.  
  281. #endif /* not  __amigados__ */
  282. typedef __WCHAR_TYPE__ wchar_t;
  283. #endif
  284. #endif
  285. #endif
  286. #endif
  287. #endif
  288. #endif
  289. #endif
  290. #endif
  291. #endif
  292. #endif
  293. #endif
  294. #endif
  295. #undef    __need_wchar_t
  296. #endif /* _STDDEF_H or __need_wchar_t.  */
  297.  
  298. /*  In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
  299.     are already defined.  */
  300. #ifdef _ANSI_H_
  301. /*  The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
  302.     are probably typos and should be removed before 2.8 is released.  */
  303. #ifdef _GCC_PTRDIFF_T_
  304. #undef _PTRDIFF_T_
  305. #undef _BSD_PTRDIFF_T_
  306. #endif
  307. #ifdef _GCC_SIZE_T_
  308. #undef _SIZE_T_
  309. #undef _BSD_SIZE_T_
  310. #endif
  311. #ifdef _GCC_WCHAR_T_
  312. #undef _WCHAR_T_
  313. #undef _BSD_WCHAR_T_
  314. #endif
  315. /*  The following ones are the real ones.  */
  316. #ifdef _GCC_PTRDIFF_T
  317. #undef _PTRDIFF_T_
  318. #undef _BSD_PTRDIFF_T_
  319. #endif
  320. #ifdef _GCC_SIZE_T
  321. #undef _SIZE_T_
  322. #undef _BSD_SIZE_T_
  323. #endif
  324. #ifdef _GCC_WCHAR_T
  325. #undef _WCHAR_T_
  326. #undef _BSD_WCHAR_T_
  327. #endif
  328. #endif /* _ANSI_H_ */
  329.  
  330. #endif /* __sys_stdtypes_h */
  331.  
  332. /* A null pointer constant.  */
  333.  
  334. #if defined (_STDDEF_H) || defined (__need_NULL)
  335. #undef NULL        /* in case <stdio.h> has defined it. */
  336. #define NULL ((void *)0)
  337. #endif    /* NULL not defined and <stddef.h> or need NULL.  */
  338. #undef    __need_NULL
  339.  
  340. #ifdef _STDDEF_H
  341.  
  342. /* Offset of member MEMBER in a struct of type TYPE.  */
  343.  
  344. #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
  345.  
  346. #endif /* _STDDEF_H was defined this time */
  347.  
  348. #endif /* __STDDEF_H__ was not defined before */
  349. #endif /* _ANSI_STDDEF_H was not defined before */
  350. #endif /* _STDDEF_H_ was not defined before */
  351. #endif /* _STDDEF_H was not defined before */
  352.